#include "ClassWithFloating.h"

QString COLUMN_NAME_ATTRIBUTEDOUBLE = "attributeDouble";
QString COLUMN_NAME_ATTRIBUTEFLOAT = "attributeFloat";
QString COLUMN_NAME_ATTRIBUTELONGDOUBLE = "attributeLongDouble";

QString COLUMN_TYPE_ATTRIBUTEDOUBLE = "double";
QString COLUMN_TYPE_ATTRIBUTEFLOAT = "float";
QString COLUMN_TYPE_ATTRIBUTELONGDOUBLE = "long double";

ClassWithFloatingBear::ClassWithFloatingBear()
{
    m_object = new BBObject;
    m_object->setName( "ClassWithFloating" );
    m_object->setAttributeType( COLUMN_NAME_ATTRIBUTEDOUBLE, COLUMN_TYPE_ATTRIBUTEDOUBLE );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEDOUBLE, NULL );
    m_object->setAttributeType( COLUMN_NAME_ATTRIBUTEFLOAT, COLUMN_TYPE_ATTRIBUTEFLOAT );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEFLOAT, NULL );
    m_object->setAttributeType( COLUMN_NAME_ATTRIBUTELONGDOUBLE, COLUMN_TYPE_ATTRIBUTELONGDOUBLE );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTELONGDOUBLE, NULL );
    addObject( m_object );
}

double ClassWithFloatingBear::getAttributeDouble()
{
    return m_object->getAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEDOUBLE ).toDouble();
}

void ClassWithFloatingBear::setAttributeDouble( double value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEDOUBLE, value );
}

float ClassWithFloatingBear::getAttributeFloat()
{
    return m_object->getAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEFLOAT ).toFloat();
}

void ClassWithFloatingBear::setAttributeFloat( float value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEFLOAT, value );
}

long double ClassWithFloatingBear::getAttributeLongDouble()
{
    return m_object->getAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTELONGDOUBLE ).toDouble();
}

void ClassWithFloatingBear::setAttributeLongDouble( long double value )
{
    double longDoubleValue = value;
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTELONGDOUBLE, longDoubleValue );
}

